const log4js = require('log4js')
log4js.configure({
	replaceConsole: true,
	// 设置 log4 日志模式
	appenders: {
		stdout: {
			//控制台输出
			type: 'console'
		},
		err: {
			//错误日志
			type: 'dateFile',
			filename: 'logs/errlog/err',
			pattern: 'yyyy-MM-dd.log',
			alwaysIncludePattern: true
		},
		other: {
			//其他日志
			type: 'dateFile',
			filename: 'logs/otherlog/other',
			pattern: 'yyyy-MM-dd.log',
			alwaysIncludePattern: true
		}
	},
	// 进行引用
	categories: {
		default: {
			appenders: ['stdout', 'other'],
			level: 'info'
		},
		err: {
			appenders: ['stdout', 'err'],
			level: 'error'
		}
	}
})

exports.getLogger = function (name) {
	return log4js.getLogger(name || 'default')
}
